//
//  RootTabBarController.m
//  HWUI09_UITabBarController
//
//  Created by 崔将军 on 16/3/21.
//  Copyright © 2016年 崔将军. All rights reserved.
//

#import "RootTabBarController.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"

@interface RootTabBarController ()

@end

@implementation RootTabBarController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        self.viewControllers = [self createRootVCs];
    }
    return self;
}

- (NSArray <UIViewController *> *)createRootVCs {
    
    NSMutableArray *arrOfVCs = [[NSMutableArray alloc] init];
    
    
    
    // First
    FirstViewController *vc1 = [[FirstViewController alloc] init];
    
    UINavigationController *first = [[UINavigationController alloc] initWithRootViewController:vc1];
    
    first.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"First" image:[UIImage imageNamed:@"wink.png"] tag:100];
    
    first.tabBarItem.badgeValue = @"+99";
    
    [arrOfVCs addObject:first];
    [vc1 release];
    [first release];
    
    // Second
    SecondViewController *vc2 = [[SecondViewController alloc] init];
    UINavigationController *second = [[UINavigationController alloc] initWithRootViewController:vc2];
    second.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Second" image:[UIImage imageNamed:@"youtube.png"] tag:200];
    second.tabBarItem.badgeValue = @"Hello";
    [arrOfVCs addObject:second];
    [vc2 release];
    [second release];
    
    // Third
    ThirdViewController *vc3 = [[ThirdViewController alloc] init];
    UINavigationController *Third = [[UINavigationController alloc] initWithRootViewController:vc3];
    Third.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Third" image:[UIImage imageNamed:@"heart.png"] tag:300];
    Third.tabBarItem.badgeValue = @"你好";
    [arrOfVCs addObject:Third];
    [vc3 release];
    [Third release];
    
    return arrOfVCs;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
